package com.ms.oschina.fragment;

import java.io.IOException;
import java.util.List;

import com.ms.oschina.adapter.BlogAdapter;
import com.ms.oschina.adapter.PageIndexListAdapter;
import com.ms.oschina.api.remote.OsChinaApi;
import com.ms.oschina.base.BaseListFragment;
import com.ms.oschina.bean.Blog;
import com.ms.oschina.tagpager.NewsFragment;

public class NewBlogsFragment extends BaseListFragment<Blog> {

	@Override
	public PageIndexListAdapter<Blog> getAdapter() {
		BlogAdapter adapter = new BlogAdapter(getListView(),
				getNetData(), true);
		int mark = getMark();
		adapter.setMark(mark);
		return adapter;
	}

	@Override
	public List<Blog> getNetData(int pageIndex) throws IOException {
		int mark = getMark();
		switch (mark) {
		case NewsFragment.BLOGS:
			return OsChinaApi.getNewsBlog(pageIndex).getBloglist();
		case NewsFragment.RECOMMEND:
			// return OsChinaApi.getNewsHotspot(pageIndex).getList();
		default:
			return null;
		}
	}
}
